package com.syyo.gulimall.product.app;

//import org.springframework.security.access.prepost.PreAuthorize;

import com.syyo.common.utils.ResultUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.syyo.gulimall.product.domain.req.CategoryBrandRelationReq;
import com.syyo.gulimall.product.service.CategoryBrandRelationService;
import com.syyo.common.domain.ResultVo;


/**
 * 品牌分类关联
 *
 * @author syyo
 * @email syyo@gmail.com
 * @date 2021-01-20 09:32:12
 */
@RestController
@RequestMapping("/product/categorybrandrelation")
public class CategoryBrandRelationController {

    @Autowired
    private CategoryBrandRelationService categoryBrandRelationService;

    /**
     * 新增
     */
    @PostMapping
    // @PreAuthorize("@syyo.check('system:categorybrandrelation:add')")
    public ResultVo add(@RequestBody CategoryBrandRelationReq req) {
        return ResultUtils.ok(categoryBrandRelationService.add(req));
    }

    /**
     * 删除
     */
    @DeleteMapping("/{id}")
    // @PreAuthorize("@syyo.check('system:categorybrandrelation:del')")
    public ResultVo del(@PathVariable("id") Integer id) {
        return ResultUtils.ok(categoryBrandRelationService.del(id));
    }

    /**
     * 修改
     */
    @PutMapping
    // @PreAuthorize("@syyo.check('system:categorybrandrelation:edit')")
    public ResultVo edit(@RequestBody CategoryBrandRelationReq req) {
        return ResultUtils.ok(categoryBrandRelationService.edit(req));
    }

    /**
     * 信息
     */
    @GetMapping("/{id}")
    public ResultVo findOne(@PathVariable("id") Integer id) {
        return ResultUtils.ok(categoryBrandRelationService.findOne(id));
    }

    /**
     * 列表
     */
    @GetMapping("/list")
    public ResultVo findPage(CategoryBrandRelationReq req) {
        return ResultUtils.ok(categoryBrandRelationService.findPage(req));
    }

    /**
     * 列表
     */
    @GetMapping("/brand/list")
    public ResultVo findAll(@RequestParam(value = "catId", required = true) Long catId) {
        return ResultUtils.ok(categoryBrandRelationService.findAll(catId));
    }

}
